<?php session_start(); ob_start();
$idUser = $_SESSION["idUser"];
$idGroup = $_SESSION["idGroup"];
$user = $_SESSION["Username"];
$quyen_xem = $_SESSION['quyen_xem'];
$quyen_action = $_SESSION['quyen_action'];
if(@$user) {
	require_once 'config.php';
	require_once 'library/layout.php';
	
	require_once DIR.'class.form.php';
	$form = new form();
	
	require_once DIR.'class.sql.php';
	$sql = new sql();
	
	$p = $_GET["p"];
	if($p=='thoat') {
		session_destroy();
		header("location:index.php");
	}
	if(!@$_SESSION['page']) $_SESSION['page'] = '';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Trang quản trị</title>
<link href="img/css.css" rel="stylesheet" type="text/css" />
<link href="script/datepicker/jquery-ui-1.8.2.custom.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="script/jquery.js"></script>
</head>

<body>
<div id="wrapper">
<div id="header"><?php require_once('header.php'); ?></div>
<div id="container">
	<div id="left">
    	<div class="title">Chức năng quản trị</div>
        <div id="catalog">
        	<?php
			$m = explode('_ac', $p); $page = $m[0];
			$k = 0;
            $menuadmin = $qt->MenuAdmin();
			while($row_menuadmin = mysql_fetch_array($menuadmin)){
				if($page != $row_menuadmin['url']) echo "<a href='administrator.php?p={$row_menuadmin[url]}'>{$row_menuadmin['ten']}</a>";
				else echo "<a href='administrator.php?p={$row_menuadmin[url]}'><font color='FF0000'>{$row_menuadmin['ten']}</font></a>";
				$k++;
				if($k == 2) echo '<hr />'; else if($k == 7) echo '<hr />'; else if($k == 10) echo '<hr />';
			}
			mysql_free_result($menuadmin);
			?>
        </div>
    </div>
    
	<div id="right">
    	<?php
		$navigator = $qt->Navigator($p);
		$row_navigator = mysql_fetch_array($navigator);
		preg_match_all("/,{$row_navigator['id']},/i", $quyen_xem, &$for_view);
		preg_match_all("/,{$row_navigator['id']},/i", $quyen_action, &$for_action);
		
		if((count($m)==1 && sizeof($for_view[0])==1) ||(count($m)==2 && sizeof($for_action[0])==1) || (!@$p) || $p=='thongtin'){
			if(@$p and $p!='home' and $p!='config' and $p!='tracuu_diemthi' and $p!='tracuu_capbang' and $p!='tracuu_hocphi' and $p!='kiemtra_hocphi') $themmoi = column_general($p);
			echo "<div class='title'><span style='float:left'>{$row_navigator[ten]}</span> {$themmoi}&nbsp;</div>";
			
			if(count($m)==1 && @$p && $page!='tracuu_diemthi' && $page!='tracuu_hocphi' && $page!='tracuu_capbang' && $page!='kiemtra_hocphi' && $page!='home' && $page!='thongtin') include_once('library/a_query.php');
			if(@$p){
				if (file_exists('blocks/'.$p.'.php')) include_once('blocks/'.$p.'.php');
				else echo "Danh mục này không tồn tại.";
			} else include_once('blocks/home.php');
			
			if(!@$_GET['btnSearch'])echo "<div id='phantrang'>{$phantrang}</div>";
		}else{
			echo '<div class="title">Thông báo</div>
			<div style="width:500px; clear:both; margin:20px 0; font-weight:bold; color:red">Bạn không có quyền vào thư mục này</div>';
		}
		?>
    </div>
</div></div>
<script type="text/javascript" src="website.js"></script>
<script type="text/javascript" src="script/datepicker/jquery.ui.core.js"></script>
<script type="text/javascript" src="script/datepicker/jquery.ui.datepicker.js"></script>
<?php
if(!@$p || $p=='home') echo '<script type="text/javascript">$("#left").hide(); $("#wrapper").css({width:730,margin:"0 auto"});</script>';
?>
</body>
</html>
<?php mysql_close();} else { echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><p>Bạn chưa đăng nhập <a href="index.php">click vào đây</a> để đăng nhập.</p>';}?>